#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct snode* stack;
struct snode {
    char ch[100];
    int top;
};
stack CreateStack();
void push(stack s, char cht);
void pop(stack s);
int IsEmpty(stack s);

int main()
{
    char s[101];
    char ans[100];
    int count = 0;
    stack st = CreateStack();
    while (1)
    {
        gets(s);
        if (s[0] == '.' && s[1] == 0)
            break;
        int l = strlen(s);
        for (int i = 0; i < l; i++)
        {
            if (s[i] == '(' || s[i] == ')' || s[i] == '{' || s[i] == '}' || s[i] == '[' || s[i] == ']')
            {
                ans[count++] = s[i];
            }
            else if (s[i] == '/' && s[i + 1] == '*')
            {
                ans[count++] = 'a';
                i++;
            }
            else if (s[i] == '*' && s[i + 1] == '/')
            {
                ans[count++] = 'b';
                i++;
            }
        }
    }
    int flag = 1;
    for (int i = 0; i < count; i++)
    {
        if (ans[i] == '(' || ans[i] == '[' || ans[i] == '{' || ans[i] == 'a')
        {
            push(st, ans[i]);
        }
        else
        {
            if (IsEmpty(st) && (ans[i] - st->ch[st->top] == 1 || ans[i] - st->ch[st->top] == 2))
            {
                pop(st);
            }
            else
            {
                printf("NO\n");
                if (IsEmpty(st) == 0)
                {
                    printf("?-");
                    if (ans[i] == 'b')
                        printf("*/\n");
                    else
                        printf("%c", ans[i]);
                }
                else
                {
                    if (st->ch[st->top] == 'a')
                        printf("/*");
                    else
                        printf("%c", st->ch[st->top]);
                    printf("-?\n");
                }
                flag = 0;
                break;
            }
        }
    }
    if (flag)
    {
        if (IsEmpty(st) == 0)
        {
            printf("YES");
        }
        else
        {
            printf("NO\n");
            if (st->ch[st->top] == 'a')
                printf("/*");
            else
                printf("%c", st->ch[st->top]);
            printf("-?\n");
        }
    }
    return 0;
}

stack CreateStack()
{

    stack s;
    s = (stack)malloc(sizeof(struct snode));
    s->top = -1;
    return s;
}

void push(stack s, char cht)
{
    s->top++;
    s->ch[s->top] = cht;
}
void pop(stack s)
{
    s->top--;
}

int IsEmpty(stack s)
{
    int flag = 1;
    if (s->top == -1)
    {
        flag = 0;
    }
    return flag;
}

